package com.example.listossimage.type;

import java.util.HashMap;
import java.util.Map;

/**
 * 广告位类型
 */
public enum AdSpaceType {

    PlateNumberPage(0, "车牌页广告"),
    PaySuccessPage(1, "支付成功页广告"),
    CarInParkingPush(2, "入场推送广告"),
    CarOutParkingPush(3, "出场推送广告"),
    CouponActivePage(4, "优惠活动广告页"),
    IndexPage(5, "首页广告"),
    PayConfirmPage(6, "支付确认页"),
    StartPage(7, "启动页"),
    PaySuccessPop(9, "支付成功弹窗广告"),
    OrderDetailsPage(11, "订单详情页广告"),
    GeneralPage(15, "一般页面广告"),
    OfficialAccountMenuPage(16, "公众号菜单栏"),
    OfflineQRCode(17, "线下二维码"),
    OtherPage(32, "其他页");


    private int index;
    private String value;

    AdSpaceType(int index, String value) {
        this.index = index;
        this.value = value;
    }

    public int getIndex() {
        return index;
    }

    public String getValue() {
        return value;
    }

    private static Map<Integer, AdSpaceType> intiAdSpaceTypeMap = new HashMap<>();

    public static AdSpaceType getAdSpaceTypeByIndex(Integer index) {
        AdSpaceType type = intiAdSpaceTypeMap.get(index);
        if (type == null) {
            for (AdSpaceType item : AdSpaceType.values()) {
                if (item.getIndex() == index) {
                    intiAdSpaceTypeMap.put(item.getIndex(), item);
                    type = item;
                    break;
                }
            }
        }
        return type;
    }


}
